/**
 * @file ResourceOptimization.vue
 * @description 智能资源优化功能页面
 * @created 2024-03-20
 */

<template>
  <div class="resource-optimization">
    <div class="page-header">
      <h2>智能优化转换</h2>
    </div>

    <!-- 优化工具区 -->
    <div class="optimization-tools">
      <div class="tool-grid">
        <div class="tool-card" v-for="tool in optimizationTools" :key="tool.id"
             @click="selectTool(tool)">
          <div class="tool-icon">{{ tool.icon }}</div>
          <h3>{{ tool.name }}</h3>
          <p>{{ tool.description }}</p>
          <div class="supported-formats">
            支持格式：{{ tool.formats.join(', ') }}
          </div>
        </div>
      </div>
    </div>

    <!-- 文件处理区 -->
    <div class="processing-area">
      <div class="upload-section">
        <div class="upload-box">
          <span class="icon">📁</span>
          <h3>拖拽文件到此处或点击上传</h3>
          <p>最大支持 500MB</p>
        </div>
      </div>

      <!-- 处理队列 -->
      <div class="processing-queue">
        <h3>处理队列</h3>
        <div class="queue-list">
          <div class="queue-item" v-for="item in processingQueue" :key="item.id">
            <div class="file-info">
              <span class="file-icon">{{ item.icon }}</span>
              <div class="file-details">
                <h4>{{ item.fileName }}</h4>
                <div class="progress-bar">
                  <div class="progress" :style="{ width: item.progress + '%' }"></div>
                </div>
                <span class="status">{{ item.status }}</span>
              </div>
            </div>
            <div class="actions">
              <button class="action-btn" v-if="item.status === '已完成'">下载</button>
              <button class="action-btn cancel" v-else>取消</button>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'

// 优化工具列表
const optimizationTools = ref([
  {
    id: 1,
    icon: '📊',
    name: 'PPT优化助手',
    description: '智能优化PPT版式、配色和动画效果',
    formats: ['PPT', 'PPTX']
  },
  {
    id: 2,
    icon: '📝',
    name: '文档格式转换',
    description: '支持多种文档格式互转，保持排版',
    formats: ['DOC', 'DOCX', 'PDF', 'TXT']
  },
  {
    id: 3,
    icon: '🎬',
    name: '视频压缩优化',
    description: '智能压缩视频，保持清晰度',
    formats: ['MP4', 'AVI', 'MOV']
  },
  {
    id: 4,
    icon: '🖼️',
    name: '图片优化工具',
    description: '批量处理图片，提升质量',
    formats: ['JPG', 'PNG', 'WEBP']
  }
])

// 处理队列
const processingQueue = ref([
  {
    id: 1,
    icon: '📊',
    fileName: '课程介绍.ppt',
    progress: 100,
    status: '已完成'
  },
  {
    id: 2,
    icon: '📝',
    fileName: '实验报告.doc',
    progress: 65,
    status: '处理中'
  }
])

// 选择工具
const selectTool = (tool) => {
  console.log('选择工具:', tool.name)
}
</script>

<style scoped>
.resource-optimization {
  padding: 24px;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.tool-card {
  background: white;
  padding: 24px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  transition: all 0.3s ease;
}

.tool-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.tool-icon {
  font-size: 36px;
  margin-bottom: 16px;
}

.supported-formats {
  margin-top: 12px;
  color: #666;
  font-size: 14px;
}

.upload-section {
  margin: 32px 0;
}

.upload-box {
  border: 2px dashed #d9d9d9;
  border-radius: 12px;
  padding: 40px;
  text-align: center;
  background: #fafafa;
  cursor: pointer;
  transition: all 0.3s;
}

.upload-box:hover {
  border-color: #1890ff;
  background: #f0f7ff;
}

.queue-list {
  background: white;
  border-radius: 12px;
  padding: 16px;
}

.queue-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid #f0f0f0;
}

.file-info {
  display: flex;
  align-items: center;
  gap: 16px;
}

.progress-bar {
  width: 200px;
  height: 6px;
  background: #f0f0f0;
  border-radius: 3px;
  margin: 8px 0;
}

.progress {
  height: 100%;
  background: #1890ff;
  border-radius: 3px;
  transition: width 0.3s ease;
}

.action-btn {
  padding: 6px 16px;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  background: #1890ff;
  color: white;
}

.action-btn.cancel {
  background: #ff4d4f;
}
</style> 